package com.zym.init.model.query;

import com.zym.init.core.annotation.EnumRange;
import com.zym.init.enums.RoleStatusEnum;
import com.zym.init.enums.StorageServiceProviderEnum;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.groups.Default;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Map;

/**
 * 存储查询对象
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class StorageQuery extends PageQuery {

    /**
     * ID
     */
    @NotNull(message = "存储ID不能为空", groups = {Update.class})
    private Long storageId;

    /**
     * 存储名称
     */
    @NotEmpty(message = "存储名称不能为空", groups = {Add.class})
    private String storageName;

    /**
     * 存储描述
     */
    private String storageDesc;

    /**
     * 存储配置
     */
    @NotNull(message = "存储配置不能为空", groups = {Update.class})
    private Map<String, String> storageConfig;

    /**
     * 状态：(1:启用[active] 2:禁用[inactive])
     */
    @EnumRange(message = "存储状态错误", enumClass = RoleStatusEnum.class, enumValidMethod = "isValidCode", groups = {Update.class, Add.class})
    @NotEmpty(message = "存储状态不能为空", groups = {Add.class})
    private String status;

    /**
     * 是否为默认存储方式：(0:false 1:true)
     */
    private Boolean isDefault;

    /**
     * 服务商
     */
    @EnumRange(message = "服务商错误", enumClass = StorageServiceProviderEnum.class, enumValidMethod = "isValidCode", groups = {Update.class, Add.class})
    @NotEmpty(message = "服务商不能为空", groups = {Add.class})
    private String serviceProvider;

    /**
     * 新增校验组
     */
    public interface Add extends Default {
    }

    /**
     * 更新校验组
     */
    public interface Update extends Default {
    }
}
